const array = [['iphone x', 'iphone xs'], ['黑色', '白色'], ['64g', '256g']];
// 输出
// [
//   ['iphone x', '黑色', '64g'],
//   ['iphone x', '白色', '64g'],
//   ['iphone x', '黑色', '256g'],
//   ['iphone x', '白色', '256g'],
//   ['iphone xs', '黑色', '64g'],
//   ['iphone xs', '白色', '64g'],
//   ['iphone xs', '黑色', '256g'],
//   ['iphone xs', '白色', '256g'],
// ];

function permute(array) {
  const res = [];
  function dfs(path) {
    if (path.length === array.length) {
      res.push([...path]);
      return;
    }
    for (let item of array[path.length]) {
      path.push(item);
      dfs(path);
      path.pop(item);
    }
  }
  dfs([]);
  return res;
}
console.log(permute(array))